//    entity language compiler Copyright (C) 2011 Vincent Belliard

//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation version 3 of the License.

//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.

//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

class T_scope ;
class T_type_method ;
class T_expression_call_access ;
class T_expression_constructor_arguments ;

class T_prototype_argument : public LINK<T_prototype_argument>
	{
public:
	T_entity_location location ;
	T_string name ;
	T_expression *type_expression ;
	T_expression *default_expression ;
	T_type *type ;
	int class_call ;
	int needs_entity ;
	int is_reference ;
	T_prototype_argument(const T_entity_location &new_location, const T_string new_name) : location(new_location), name(new_name) { type_expression = NULL ; default_expression = NULL ; type = NULL ; class_call = FALSE ; needs_entity = FALSE ; is_reference = FALSE ; }
	void dump(FILE *file) const ;
	void parse(T_entity_compiler *compiler) ;
	void verify_semantic(T_entity_compiler *compiler, T_entity_program *program, T_scope *scope, T_type_method *method_type, T_object_class *object_class) ;
	int can_overload(const T_prototype_argument *ref) ;
	} ;

class T_prototype
	{
public:
	LIST<T_prototype_argument> arguments ;
	int specialization ;
	T_prototype(void) { specialization = FALSE ; }
	void dump(FILE *file) const ;
	int parse(T_entity_compiler *compiler) ;
	void verify_semantic(T_entity_compiler *compiler, T_entity_program *program, T_scope *scope, T_type_method *method_type, T_object_class *object_class) ;
	int can_overload(const T_prototype *ref) const ;
	int is_good_for_call(T_entity_program *program, T_expression_constructor_arguments *call) const ;
	int is_good_for_constructor(T_entity_program *program, T_expression_constructor_arguments *constructor) const ;
	void generate_prototype(FILE *file, int first) const ;
	void generate_specialization(T_entity_program *program, FILE *file, int false_label) ;
	} ;
